<?php
ob_start();
session_start();
// --------- config ---------------
require '../config/database.php';
require '../config/config_var.php';
$config_var			= new config_var();

// --------- function ---------------
require '../include/functions/functions.php';
$func				= new functions();

// --------- database ---------------
require '../application/model/database.php';
$database 			= new database();
$database->Connect(); 

require '../application/model/language_class.php';
require '../application/model/useradmin_class.php';
require '../application/model/interfaces_class.php';
require '../application/model/news_type_class.php';
require '../application/model/news_detail_class.php';
require '../application/model/news_class.php';
require '../application/model/connective_class.php';
require '../application/model/support_class.php';
require '../application/model/contact_class.php';
//require '../application/model/log_useradmin_class.php';

$language_class				= new language();
$useradmin_class			= new useradmin();
$interfaces_class			= new interfaces();
$news_type_class			= new news_type();
$news_detail_class			= new news_detail();
$news_class					= new news();
$connective_class			= new connective();
$support_class				= new support();
$contact_class				= new contact();

// --------- language ---------------
require '../language/config_nc.php';
require '../language/news_type_nc.php';
require '../language/news_detail_nc.php';
require '../language/news_nc.php';
require '../language/connective_nc.php';
require '../language/support_nc.php';
require '../language/contact_nc.php';
$WEB_LANGUAGE				= $func->GetSession('WEB_LANGUAGE');
if(isset($_POST['wlanguage'])){
	$WEB_LANGUAGE = $_POST['wlanguage'];
	$func->SetSession('WEB_LANGUAGE',$WEB_LANGUAGE);
}
$config_nc					= new Config_nc($WEB_LANGUAGE);
$news_type_nc				= new news_type_nc($WEB_LANGUAGE);
$news_detail_nc				= new news_detail_nc($WEB_LANGUAGE);
$news_nc					= new news_nc($WEB_LANGUAGE);
$connective_nc				= new connective_nc($WEB_LANGUAGE);
$support_nc					= new support_nc($WEB_LANGUAGE);
$contact_nc					= new contact_nc($WEB_LANGUAGE);

$WEB_DOMAIN					= $config_var->WEB_DOMAIN;
$WEB_ADMIN					= 'admincp';
$WEB_IP						= $func->getRealIPAddress();
$WEB_SESSIONID				= session_id();
$Row_Language   			= $language_class->GetByAll();


if($func->sql_injection()){	
	$WEB_PAGE = 'home';
	$WEB_PAGE= $func->html_get('u1');
	if($config_var->ADMIN_TIMELOGOUT>0 && isset($_SESSION['user_admin_time'])){
		if($_SESSION['user_admin_time']+$config_var->ADMIN_TIMELOGOUT<time()){
			$func->DelSession('user_admin');
		}
	}
	if(isset($_SESSION['user_admin'])){
		$WEB_UserAdmin		= $_SESSION['user_admin'];		
		switch($WEB_PAGE){		
			case "_my-account" :			include('controller/_my_account.php'); break;
			case "_logo" :					include('controller/_logo.php'); break;
			case "_banner" :				include('controller/_banner.php'); break;
			case "_information" :			include('controller/_information.php'); break;
			case "_contact-me" :			include('controller/_contact_me.php'); break;
			case "_about-me" :				include('controller/_about_me.php'); break;
			case "_logout" :				include('controller/_logout.php'); break;
			case "_news-category" :			include('controller/_news_category.php'); break;
			case "_news" :					include('controller/_news.php'); break;	
			
			case "_support" :				include('controller/_support.php'); break;		
			case "_connective" :			include('controller/_connective.php'); break;				
			default:						include('view/default/home.php'); break;	
		}			
	}else{
		switch($WEB_PAGE){		
			case "_login" :					include('controller/_login.php'); break;
			default:						include('view/login.php'); break;	
		}	
	}	
}else{
	header('Location:../error.html');
}

?>